#include <iostream>
using namespace std;

signed main()
{
    string s;
    int n;
    cin>>s>>n;
    for(int i=1;i<n;i++){
        string ans;
        s.append(1,'-');
        int num = 1;
        char c = s[0];
        for(int j=1;j<s.size();j++){
            if(s[j]!=c){
                ans.append(1,c);
                ans.append(1,char(num+'0'));
                c = s[j];
                num = 1;
            }
            else    num++;
        }
        s = ans;
    }
    cout<<s+'\n';
    return 0;
}
